2wirespiiso 2.2.0
Loading...
Searching...
No Matches
2wirespiiso


2-Wire SPI ISO Click

2-Wire SPI ISO Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Nov 2023.
  • Type : SPI type

Software Support

Example Description

This example demonstrates the use of a 2-Wire SPI ISO Click board by showing the communication between the two Click boards (Slave and Master). That is performed by sending commands to a 2-Wire SPI ISO Click (Slave) to read the device ID of a Accel 22 Click board connected to the 2-Wire SPI ISO Click (Master).

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.2WireSPIISO

Example Key Functions

Application Init

Initializes the driver and performs the Click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
c2wirespiiso_cfg_t c2wirespiiso_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
c2wirespiiso_cfg_setup( &c2wirespiiso_cfg );
C2WIRESPIISO_MAP_MIKROBUS( c2wirespiiso_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == c2wirespiiso_init( &c2wirespiiso, &c2wirespiiso_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
c2wirespiiso_default_cfg ( &c2wirespiiso );
log_info( &logger, " Application Task " );
}
#define C2WIRESPIISO_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition c2wirespiiso.h:97
void application_init(void)
Definition main.c:49

Application Task

Reads and checks the device ID of a Accel 22 Click board connected to the 2-Wire SPI ISO (Master) Click, and displays the results on the USB UART approximately once per second.

void application_task ( void )
{
c2wirespiiso_get_accel22_id ( &c2wirespiiso );
Delay_ms ( 1000 );
}
void c2wirespiiso_get_accel22_id(c2wirespiiso_t *ctx)
2-Wire SPI ISO get Accel 22 ID function.
Definition main.c:103
void application_task(void)
Definition main.c:80

Note

The communication topology is as follows:

  • MCU <-> 2-Wire SPI ISO Click (Slave) <-> 2-Wire SPI ISO Click (Master) <-> Accel 22 Click

The Master/Slave selection is done via on-board SMD jumpers. The Master Click board must be powered up with a 3V3 and 5V power supply externally. Also the DIS must be pulled down on Master Click board to enable the device.

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.